#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
认证领域接口

定义认证领域的服务和接口
"""

from abc import ABC, abstractmethod
from typing import Any, Dict, Optional

from app.domains.user.model import User


class IAuthService(ABC):
    """认证服务接口"""
    
    @abstractmethod
    def register_user(self, user_data: Dict[str, Any]) -> User:
        """注册用户
        
        Args:
            user_data: 用户数据
            
        Returns:
            User: 注册成功的用户
        """
        pass
    
    @abstractmethod
    def login(self, username: str, password: str) -> Dict[str, Any]:
        """用户登录
        
        Args:
            username: 用户名
            password: 密码
            
        Returns:
            Dict[str, Any]: 包含用户信息和令牌的字典
        """
        pass
    
    @abstractmethod
    def verify_token(self, token: str) -> Optional[User]:
        """验证令牌
        
        Args:
            token: 令牌
            
        Returns:
            Optional[User]: 验证成功则返回用户对象，否则返回None
        """
        pass
    
    @abstractmethod
    def get_mock_user(self) -> Dict[str, Any]:
        """获取模拟用户数据
        
        Returns:
            Dict[str, Any]: 模拟用户数据
        """
        pass


class ITokenService(ABC):
    """令牌服务接口"""
    
    @abstractmethod
    def generate_token(self, user_id: str) -> str:
        """生成令牌
        
        Args:
            user_id: 用户ID
            
        Returns:
            str: 生成的令牌
        """
        pass
    
    @abstractmethod
    def verify_token(self, token: str) -> Optional[str]:
        """验证令牌
        
        Args:
            token: 令牌
            
        Returns:
            Optional[str]: 验证成功则返回用户ID，否则返回None
        """
        pass
    
    @abstractmethod
    def revoke_token(self, token: str) -> bool:
        """撤销令牌
        
        Args:
            token: 令牌
            
        Returns:
            bool: 撤销成功则返回True，否则返回False
        """
        pass 